/**
  ******************************************************************************
  * @file    Project/STM32F4xx_StdPeriph_Templates/main.c 
  * @author  MCD Application Team
  * @version V1.8.0
  * @date    04-November-2016
  * @brief   Main program body
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include "usart_stdio.h"
#include "screen.h"
#include "spi_flash.h"
#include "led.h"
#include "base_timer.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
void BaseTimerProcess(void);
/* Private functions ---------------------------------------------------------*/

/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
	uint32_t uiFlashID;
	
	USART_Stdio_Initialize(115200);
	printf("Usart stdio configure done.\r\n");

	SCREEN_Initialize();
	printf("Screen device configure done.\r\n");
	SCREEN_Fill(0x0F);
	SCREEN_Fill(0xF0);

	SPI_FLASH_Initialize();
	printf("SPI flash configure done.\r\n");
	uiFlashID = SPI_FLASH_ReadID();
	printf("Flash chip ID is 0x%06X.\r\n", uiFlashID);

	LED_Initialize();
	LED_Off();
	printf("LED configure done.\r\n");
	
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
	BASE_TIMER_Initialize(TIM3, 4999, 7199);
	TIM3_ConfigReceiveInterrupt(BaseTimerProcess, 0, 0);
	BASE_TIMER_ActiveInterrupt(TIM3, true);
	printf("Base timer configure done.\r\n");
	
    /* Infinite loop */
    while (1)
    {
    }
}

#ifdef  USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{ 
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif

void BaseTimerProcess(void)
{
	LED_Reverse();
}


/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
